﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Model_Layer;
using Data_Access_Layer;

namespace Business_Logic_Layer
{
    public class BLLFlight
    {
        private static IDBFlight dbFlight = new DBFlight();
        private static IDBFlight dbFlights = new DBFlight();

        //without singlewhere
        //public Flight getSelectedFlight(int idflight)
        //{
        //    try { return dbFlight.getSelectedFlight(idflight); }
        //    catch (Exception ex) { throw new Exception(ex.Message); }
        //}



        //With Michwhere
        public List<Flight> GetAllFlights(bool retrieveAssociation)
        {
            try
            {
                return dbFlights.GetAllFlights(retrieveAssociation);
            }
            catch(Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }


        public List<Flight> GetCriteriaFlights(string wClause, bool retrieveAssociation)
        {
            try
            {
                return dbFlight.GetCriteriaFlights(wClause, retrieveAssociation);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }

        //With SingleWhere
        public Flight getSelectedFlight(int idflight)
        {
            try 
            { 
                return dbFlight.getSelectedFlight(idflight, true); 
            }
            catch (Exception ex) 
            { 
                throw new Exception(ex.Message); 
            }
        }

    }
}

